<template>
	<view class="flex-col page">
		<view class="flex-col group_1">
			<view class="flex-row">
				<text class="text_1">新密码</text>
				<input type="input" v-bind:password="true" v-model="news_password" placeholder="请输入新密码"
					class="text_2" />
			</view>
			<view class="flex-row group_3">
				<text class="text_1">确认新密码</text>
				<input type="input" v-bind:password="true" v-model="repeat_password" placeholder="请再次输入新密码"
					class="text_2" />
			</view>
			
			<view class="divider">
				<!--*-->
			</view>
			<view class="flex-col button" @click="submits">
				<view class="section_2">
					<text class="text_9">完成</text>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				news_password: '',
				repeat_password: '',
			};
		},
		methods: {
			submits() {
				
				if (this.news_password == '') {
					this.$u.toast('请输入新密码');
					return;
				}
				if (this.repeat_password == '') {
					this.$u.toast('请输入新密码');
					return;
				}
				if (this.news_password != this.repeat_password) {
					this.$u.toast('新密码和确认新密码不一致');
					return;
				}


				let reg = new RegExp(/^(?![^a-zA-Z]+$)(?!\D+$)/);
				if (!reg.test(this.news_password)) {
					this.$u.toast('密码格式错误,至少6位(字母+数字)');
					return;
				}

				this.$http('user.changePasswordByCode', {
					newPassword: this.news_password
				}).then(r => {
					console.log(r)
					if (r.code == 200) {
						this.$u.toast(r.msg);
					
							this.go('/pages/index/my',true);
					
					} else {
						this.$u.toast(r.msg);
					}
				});
				console.log(this.repeat_password)

			}
		},
	};
</script>

<style scoped lang="scss">
	.text_2 {
		margin-left: 40rpx;
	}

	.group_3 {
		margin-top: 41rpx;
		padding-top: 30rpx;
		border-top: solid 1rpx #eeeeee;
	}

	.page {
		background-color: #ffffffff;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		height: 100%;
	}

	.group_1 {
		padding: 25.5rpx 0 595rpx 32rpx;
		flex: 1 1 auto;
		overflow-y: auto;
	}

	.button {
		margin-top: 187rpx;
		padding-bottom: 6rpx;
		position: relative;
	}

	.text_1 {
		font-weight: 500;
		color: #333333;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
		width: 180rpx;

	}

	.text-wrapper {
		position: absolute;
		left: 311rpx;
		top: 56rpx;
	}

	.divider {
		margin-top: 42rpx;
		background-color: #eeeeee;
		height: 1rpx;
	}

	.text_3 {
		color: #333333;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}

	.section_2 {
		margin-right: 32rpx;
		background-color: #1d6aff;
		border-radius: 60rpx;
		height: 88rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.text_9 {
		color: #ffffff;
		font-size: 32rpx;
		font-family: '.AppleSystemUIFont';
		line-height: 38rpx;
	}
</style>
